<?php

namespace app\home\controller\ai;

use app\common\controller\BaseController;
use app\common\service\ai\AiVoiceService;
use hg\apidoc\annotation as Apidoc;

/**
 * @Apidoc\Title("AI音频管理")
 * @Apidoc\Group("ai")
 * @Apidoc\Sort("300")
 */
class AiVoice extends BaseController {
    
    /**
     * 表名
     * @static string
     */
    protected static $table = 'voice';
    
    /**
     * @Apidoc\Title("列表")
     * @Apidoc\Param(ref="app\common\model\ai\AiVoiceModel", field="member_id")
     * @Apidoc\Returned("list", type="array", desc="列表", children={
     * @Apidoc\Returned(ref="app\common\model\ai\AiVoiceModel", withoutField="sdc"),
     * @Apidoc\Returned(ref="app\common\model\ai\OrderModel", field="order_no"),
     * })
     */
    public function getList() {
        $list = AiVoiceService::getListByHome($this->data);
        return success($list);
    }
    
    /**
     * @Apidoc\Title("生成")
     * @Apidoc\Method("POST")
     * @Apidoc\Param(ref="app\common\model\ai\AiVoiceModel", field="member_id,name,pitch_ratio,speed_ratio,volume_ratio,speaker_id,text")
     */
    public function build() {
        return AiVoiceService::build($this->data);
    }
    
    /**
     * @Apidoc\Title("删除")
     * @Apidoc\Method("POST")
     * @Apidoc\Param(ref="app\common\model\ai\AiVoiceModel", field="id")
     */
    public function del() {
        return AiVoiceService::del($this->data);
    }
    
    /**
     * @Apidoc\Title("下拉列表")
     * @Apidoc\Param(ref="app\common\model\ai\AiVoiceModel", field="member_id")
     * @Apidoc\Returned("list", type="array", desc="列表", children={
     * @Apidoc\Returned(ref="app\common\model\ai\AiVoiceModel", withoutField="sdc"),
     * })
     */
    public function getListBySelect() {
        $list = AiVoiceService::getListBySelect($this->data);
        return success($list);
    }
	
	/**
     * @Apidoc\Title("点数")
	 * @Apidoc\Param(ref="app\common\model\ai\AiVoiceModel", field="text")
     * @Apidoc\Returned(ref="app\common\model\ai\OrderModel", field="point")
     */
    public function getPoint() {
        $point = AiVoiceService::getPoint($this->data);
        return success(['point' => $point]);
    }

}
